import Vue from 'vue'
import Vuex from 'vuex'
import VuexPersistence from 'vuex-persist'

Vue.use(Vuex)


const vuexLocal = new VuexPersistence({
  storage: window.sessionStorage
})

export default new Vuex.Store({
  state: {
    token: '',
  },
  mutations: {
    setToken(state, token) {
      state.token = token
    },
  },
  actions: {
    asyncSetToken(context, args) {
      context.commit('setToken', args)
    },
  },
  plugins: [vuexLocal.plugin]
})